package cn.ztuo.bitrade.controller.contract;


import cn.ztuo.bitrade.controller.common.BaseAdminController;
import cn.ztuo.bitrade.entity.ContractPosition;
import cn.ztuo.bitrade.service.ContractPositionService;
import cn.ztuo.bitrade.util.MessageResult;
import cn.ztuo.bitrade.vo.position.ContractPositionFindReqVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@Api(value = "仓位管理",tags = "仓位管理")
@RequestMapping(value="product/position")
public class ContractPositionController extends BaseAdminController {
    @Autowired
    private ContractPositionService positionService;
    /**
     * 查询默认交易对儿
     * @return
     */
    @RequestMapping(value = "/findPositions",method = RequestMethod.POST)
    public MessageResult findPositions(ContractPosition position){
            List<ContractPosition> list = positionService.findPositions(position);
            return success(list);
    }

    @ApiOperation(value = "列表查询分页", notes = "列表查询分页")
    @RequestMapping(value = "/findAllByPage", method = RequestMethod.POST)
    public MessageResult findAllByPage(@Validated ContractPositionFindReqVo reqVo) {
        Page<ContractPosition> page = positionService.findAllByPage(reqVo);
        return MessageResult.getSuccessInstance("", page);
    }
}
